Skip to content

feat(timeouts): execution timeout limits#3120

Merged
icecrasher321 merged 28 commits intostagingfrom
feat/timeout-lims
Feb 4, 2026
Merged

feat(timeouts): execution timeout limits#3120
icecrasher321 merged 28 commits intostagingfrom
feat/timeout-lims

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Feb 3, 2026

Summary

Execution Timeouts.

Only for sync executions [Free -- 5min, Paid - 1 hour]. Async is 10 min for free and 90 min for paid.

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 4, 2026 6:00pm

Request Review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 4, 2026

Greptile Overview

Greptile Summary

This PR introduces plan-based execution timeout limits for workflow executions.

Key Changes:

  • Created new execution-limits module with plan-aware timeout configuration (Free: 5min sync, Paid: 60min sync, All: 90min async)
  • Updated all execution callsites to use new timeout system: workflow executions, MCP tools, browser automation, and Trigger.dev async jobs
  • Added proper timeout error handling with ExecutionTimeoutError class, isTimeoutError() detection, and formatted error messages
  • Integrated timeout enforcement into SSE and non-SSE execution paths with AbortSignal.timeout() and manual AbortController patterns
  • Updated documentation and pricing pages to reflect new timeout limits
  • Added environment variable overrides for each plan tier (EXECUTION_TIMEOUT_FREE, EXECUTION_TIMEOUT_PRO, etc.)

Architecture:
The implementation flows through preprocessExecution() which fetches user subscription and determines timeouts, passing them to execution routes which enforce limits via abort signals. Timeouts are properly logged and return 408 status codes.

Issues Found:

  • Test assertions in apps/sim/lib/mcp/utils.test.ts are hardcoded to 300000ms but actual values now vary by plan, causing test failures

Confidence Score: 4/5

  • Safe to merge after fixing test failures, comprehensive timeout implementation with proper error handling
  • Implementation is thorough and follows good patterns (centralized config, plan-aware limits, proper abort signals, error handling). Test failures will break CI and must be fixed before merge. No logic bugs detected.
  • Fix apps/sim/lib/mcp/utils.test.ts test assertions to match new plan-based timeout behavior

Important Files Changed

Filename Overview
apps/sim/lib/core/execution-limits/types.ts New core timeout configuration system with plan-based limits (5min free, 60min paid sync; 90min async)
apps/sim/lib/mcp/utils.test.ts Test expectations hardcoded to 300000ms (5min) but actual value now varies by plan
apps/sim/app/api/workflows/[id]/execute/route.ts Added timeout enforcement with proper error handling, logging, and 408 status codes for timeouts
apps/sim/lib/execution/preprocessing.ts Added execution timeout metadata to preprocessing result based on user subscription plan
apps/sim/trigger.config.ts Increased Trigger.dev maxDuration from 600s (10min) to 5400s (90min) for async jobs
apps/docs/content/docs/en/execution/costs.mdx Added execution time limits documentation, but async limit documented as 90min while code uses 90min (5400s)

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as Execute API
    participant PreProc as preprocessExecution
    participant Billing as Subscription Service
    participant Limits as Execution Limits
    participant Executor as Workflow Executor
    participant Logger as Logging Session

    Client->>API: POST /api/workflows/{id}/execute
    API->>PreProc: preprocessExecution(workflowId, userId)
    PreProc->>Billing: getHighestPrioritySubscription(userId)
    Billing-->>PreProc: userSubscription (plan: free|pro|team|enterprise)
    PreProc->>Limits: getExecutionTimeout(plan, 'sync')
    Limits-->>PreProc: timeout (5min|60min)
    PreProc->>Limits: getExecutionTimeout(plan, 'async')
    Limits-->>PreProc: timeout (90min)
    PreProc-->>API: executionTimeout: {sync, async}
    
    alt SSE Execution
        API->>API: Setup AbortController + setTimeout(syncTimeout)
        API->>Executor: executeWorkflow(abortSignal)
        alt Timeout Occurs
            API->>Executor: abortController.abort()
            Executor-->>API: result.status = 'cancelled'
            API->>Logger: markAsFailed(timeoutErrorMessage)
            API->>Client: SSE execution:error (408)
        else Success
            Executor-->>API: result (outputs, logs)
            API->>Logger: complete()
            API->>Client: SSE execution:completed
        end
    else Non-SSE Execution
        API->>Executor: executeWorkflow(AbortSignal.timeout(syncTimeout))
        alt Timeout Occurs
            Executor-->>API: throws TimeoutError
            API->>Limits: isTimeoutError(error)
            Limits-->>API: true
            API->>Limits: getTimeoutErrorMessage(error, syncTimeout)
            Limits-->>API: "Execution timed out after X minutes"
            API->>Logger: safeCompleteWithError()
            API->>Client: JSON error (408)
        else Success
            Executor-->>API: result
            API->>Logger: complete()
            API->>Client: JSON result (200)
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@icecrasher321 icecrasher321 merged commit a627faa into staging Feb 4, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/timeout-lims branch February 5, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant